
//
// An example of encoding/decoding object
//

package main

import "encoding/gob"
import "fmt"
import "os"

type Op struct {
    X int
    Y int
}

func writeOp() {
    op := Op{10, 10}

    fo, _ := os.Create("a.bin")
    defer fo.Close()

    enc := gob.NewEncoder(fo)
    enc.Encode(op)
} 

func readOp() {
    fi, _ := os.Open("a.bin")
    defer fi.Close()
   
    var op Op
    dec := gob.NewDecoder(fi)
    dec.Decode(&op)
    
    fmt.Printf("Get op: %v\n", op)
}

func main() {
   writeOp()
   readOp()
}
